import React from 'react'
import { Row,Col } from 'antd'
import './index.less'
import Util from './../../utils/utils'
import Cookies from  'js-cookie'


export default class Header extends React.Component{

    constructor(props) {
        super(props);
        this.logout=this.logout.bind(this)
    }

    componentWillMount(){
        this.setState({
            userName:'龙行天下'
        })
        setInterval(() => {
            let sysTime = Util.formatDate(new Date().getTime());
            this.setState({
                sysTime
            })
        },1000)
    }
    logout(){
        Cookies.remove('token')
    }

    render(){
        return(
            <div className="header">
                <Row className="header-top">
                    <Col span="24">
                        <span>欢迎 : { this.state.userName }</span>
                        <a href="www.baidu.com" onClick={this.logout}>退出</a>
                    </Col>
                </Row>
                <Row className="breadcrumb">
                    <Col span="4" className="breadcrumb-title">
                        看板
                    </Col>
                    <Col span="20" className="weather">
                        <span className="date">{ this.state.sysTime }</span>
                        <span className="weather-detail">晴转多云</span>
                    </Col>
                </Row>
            </div>
        )
    }
}